<template>
  <h1>helloWold组件</h1>
  <p>组件内容接收传递参数:{{ nums }}</p>
  <p>组件内容接收传递参数:{{ vv }}</p>
  <button @click="test">点击修改价格</button>
  <Foo></Foo>
</template>

<script>
import Foo from "./Foo.vue";
import { inject, watch } from "@vue/runtime-core";
import { ref } from "vue";
export default {
  name: "HelloWorld",
  components: { Foo },
  setup() {
    let nums = inject("cash");
    let vv = ref(20);

    function test() {
      this.vv += 2;
    }

    // 组件监视
    watch([vv], (newValue, oldValue) => {
      console.log("监视开启了");
    });
    return {
      nums,
      vv,
      test,
    };
  },
};
</script>

<style>
</style>